﻿namespace BooDoo

import System
import System.Collections
import Boo.Lang.Useful

class Program:
	private cmdline = BooDooCommandLine()
	
	static def PrintBanner():
		print "BooDoo v. ----, (CLR v.${Environment.Version})"
		print
	
	def PrintUsage():
		print ResourceManager.Instance.GetString("BooDoo.UsageText")
		cmdline.PrintOptions()
	
	def Main(argv as (string)):
		PrintBanner()
		
		try:
			cmdline.Parse(argv)
		except moe as Boo.Lang.Useful.CommandLine.MalformedOptionException:
			print "Malformed Argument: ${moe.Message}"
			print "Do not place a space after the colon for arguments" if moe.Message.ToCharArray()[-1] == char(':')
			print
			PrintUsage()
			return 1
		except cle as Boo.Lang.Useful.CommandLine.CommandLineException:
			print "Command Line Exception: ${cle.Message}"
			print
			PrintUsage()
			return 1
		except e as object:
			print "Unexpected Exception Occured"
			print e.ToString()
			return 1
		
		return 0
	
[STAThread]
static def Main(argv as (string)):
	return Program().Main(argv)

